#include "uart.h"
#include "stdio.h"
#include "string.h"

#include "Variant.h"


U8_T uart1_count;




Msg_t uart1_data = {0};
uint8_t uart1_data_index = 0;
int uart1_rx_flag = 0;

int uart1_rx_handle()
{
	int tmp = 0;

	if(uart1_rx_flag)
	{
		if(uart1_data_index >= 30 || uart1_count >= 10)
		{
			uart1_rx_flag = 0;			
			return uart1_data.index;			
		}
	}
	else
		uart1_count = 0;
	return 0;
}


void my_printf(char *fmt,...)
{
	char buf[100] = {0};
	uint16_t i = 0;
	va_list arg_ptr;
	va_start(arg_ptr, fmt);
	vsnprintf(buf, 100, fmt, arg_ptr);

	while(i<99 && buf[i])
	{
		UARTTransmit(UART2, (uint8_t *)&buf[i], 1);
		i++;
	}
	va_end(arg_ptr);
}

void hex_debug(uint8_t *data, uint16_t size)
{
	int i = 0;
	for(i=0; i<size; i++)
		apt_printf("%02X ", data[i]);
	apt_printf("\r\n");
}




